#定义一个10个元素的列表，通过列表自带的函数，实现元素在尾部插入和头部插入并记录程序运行的时间；用deque来实现，同样记录程序所耗费的时间；输出这2个时间的差值；

import time
from collections import deque
list1 = [ 0,1,2,3,4,5,6,7,8,9  ]
time1_1 = time.time()
list1.insert( 0, -1 )
list1.append( 10 )
time1_2 = time.time()
timedifference1 = time1_2 - time1_1
print(list1)

deque1 = deque( ['0','1','2','3','4','5','6','7','8','9'] )
time2_1 = time.time()
deque1.appendleft( '-1' )
deque1.append( '10' )
time2_2 = time.time()
timedifference2 = time2_2 - time2_1
print(deque1)

if timedifference1 < timedifference2:
    print( 'list is faster, timedifference is: ', ( timedifference2 - timedifference1 ) )
elif timedifference1 > timedifference2:
    print( 'deque is faster, difference is: ', ( timedifference1 - timedifference2 ) )
else:
    print( 'Same!' )